package com.gitee.dufafei.plugin.consts;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Const {

    public static String FILE_SEPARATOR = System.getProperty("file.separator");

    public static String replace(String string, String repl, String with) {
        if (string != null && repl != null && with != null) {
            return string.replaceAll(Pattern.quote(repl), Matcher.quoteReplacement(with));
        } else {
            return null;
        }
    }

    public static int indexOfString(String lookup, String[] array) {
        if (array == null) {
            return -1;
        }
        if (lookup == null) {
            return -1;
        }
        for (int i = 0; i < array.length; i++) {
            if (lookup.equalsIgnoreCase(array[i])) {
                return i;
            }
        }
        return -1;
    }

    public static String NVL(String source, String def) {
        if (source == null || source.length() == 0) {
            return def;
        }
        return source;
    }
}
